home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / basic / imb9009.zip / ISAMTEST.BAS
BASIC Source File  |  1990-09-04  |  3KB  |  92 lines

  1. 'PROGRAM - ISAMTEST.BAS
  2.  
  3. '****************************************************************
  4. '** Purpose - This program demonstrates the essential elements  *
  5. '**           you incorporate in programs using the ISAM engine *
  6. '****************************************************************
  7.  
  8.   CLS
  9.  
  10. '******************  Setup ISAM file  **************************
  11.  
  12.   TYPE BusMailList              'Definition for ISAM table
  13.     FirstName AS STRING * 15
  14.     LastName  AS STRING * 15
  15.     Company   AS STRING * 30
  16.     Address   AS STRING * 30
  17.     City      AS STRING * 20
  18.     State     AS STRING * 2
  19.     Zip       AS STRING * 5
  20.   END TYPE
  21.  
  22.   DIM ML AS BusMailList         'Record variable to move data
  23.                                 '  in and out of file
  24.  
  25.   OPEN "MailList.MDB" FOR ISAM BusMailList "BusinessList1" AS #1
  26.  
  27. ' Use the CREATEINDEX cmd only if the index does not exist
  28.  
  29.   CREATEINDEX #1, "B1Zip", 0, "Zip"
  30.   SETINDEX #1, "B1Zip"               'Set the active index
  31.  
  32. '*******************  Add records to file **********************
  33.  
  34.   INPUT "Add a record to the file (Y/N)"; Response$
  35.   
  36.   WHILE UCASE$(Response$) = "Y"
  37.  
  38.     CLS
  39.  
  40.     PRINT "Enter the following information"
  41.     PRINT
  42.  
  43.     LINE INPUT "First name: "; ML.FirstName
  44.     LINE INPUT "Last name : "; ML.LastName
  45.     LINE INPUT "Company   : "; ML.Company
  46.     LINE INPUT "Address   : "; ML.Address
  47.     LINE INPUT "City      : "; ML.City
  48.     LINE INPUT "State     : "; ML.State
  49.     LINE INPUT "Zip       : "; ML.Zip
  50.  
  51.     INSERT #1, ML
  52.     PRINT
  53.     INPUT "Add another record to the file (Y/N)"; Response$
  54.  
  55.   WEND
  56.  
  57. '******  Sequentially display records from file *****************
  58.  
  59.   MOVEFIRST #1                          'Set initial file postion
  60.  
  61.   NbrRecs = LOF(1)  'For ISAM files, LOF returns the # of records
  62.  
  63.   FOR RecNbr = 1 TO NbrRecs
  64.  
  65.     CLS
  66.     
  67.     RETRIEVE #1, ML                     'Get the next ISAM record
  68.  
  69.     PRINT "Business mailing list display"
  70.     PRINT
  71.     PRINT "First name: "; ML.FirstName
  72.     PRINT "Last name : "; ML.LastName
  73.     PRINT "Company   : "; ML.Company
  74.     PRINT "Address   : "; ML.Address
  75.     PRINT "City      : "; ML.City
  76.     PRINT "State     : "; ML.State
  77.     PRINT "Zip       : "; ML.Zip
  78.     PRINT
  79.     INPUT "Press <Enter> to see the next record."; Response$
  80.  
  81.     MOVENEXT #1                         'Advance next record
  82.     
  83.   NEXT RecNbr
  84.  
  85.   PRINT
  86.   PRINT "End of file reached."
  87.   PRINT "Terminating program."
  88.  
  89.   CLOSE 1
  90.   END
  91.  
  92.